package com.collins.thread.practices.drawLottery;

import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.concurrent.TimeUnit;

public class Watcher implements Runnable {

    SimpleDateFormat df = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");

    @Override
    public void run() {
        while (true) {
            try {
                // Thread.sleep(500);
                TimeUnit.MILLISECONDS.sleep(500);
            } catch (InterruptedException e) {
                throw new RuntimeException(e);
            }
            for (String key : Host.dataLocal.keySet()) {
                System.out.println(df.format(new Date(System.currentTimeMillis()))
                        + "-notification: " + key + " has lotteries: " + Host.dataLocal.get(key));
            }
        }
    }
}
